package com.mtsmda.jpa.run;

import javax.persistence.EntityManager;
import javax.persistence.Persistence;

import com.mtsmda.jpa.domain.perClassTable.DotNetProgrammer;
import com.mtsmda.jpa.domain.perClassTable.JavaProgrammer;
import com.mtsmda.jpa.domain.perClassTable.Programmer;

public class ProgrammerServiceRun {

	public static void main(String[] args) {
		EntityManager entityManager = Persistence.createEntityManagerFactory(
				"MTSMDA").createEntityManager();
		entityManager.getTransaction().begin();

		Programmer programmer = new Programmer(true, false);

		JavaProgrammer javaProgrammer1 = new JavaProgrammer(true, true,
				"JAX-B, DOM, SAX", true);
		JavaProgrammer javaProgrammer2 = new JavaProgrammer(true, false, "SAX",
				false);

		DotNetProgrammer dotNetProgrammer1 = new DotNetProgrammer(true, true,
				true, "ASP, Windows Forms");
		DotNetProgrammer dotNetProgrammer2 = new DotNetProgrammer(false, true,
				false, "Windows Forms");

		entityManager.persist(programmer);
		
		entityManager.persist(javaProgrammer1);
		entityManager.persist(javaProgrammer2);
		entityManager.persist(dotNetProgrammer1);
		entityManager.persist(dotNetProgrammer2);

		entityManager.getTransaction().commit();
		entityManager.close();
	}

}